// run: $exec < input
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>

struct data
{
	long long l, r, ans;
};

int const maxn = 2000;
data query[maxn];
long long a[maxn];
int n, q;

long long gcd(long long x, long long y)
{
	return !y ? x : gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
	return x * y / gcd(x, y);
}

int main()
{
	std::ios::sync_with_stdio(false);
	int T; std::cin >> T;
	while (T--) {
		std::cin >> n >> q;
		std::memset(a, 0, sizeof(a));
		for (int i = 0; i < q; i++) {
			long long l, r, ans;
			std::cin >> l >> r >> ans;
			query[i].l = l; query[i].r = r; query[i].ans = ans;
			for (int j = l; j <= r; j++) {
				if (!a[j]) a[j] = ans;
				else a[j] = lcm(a[j], ans);
			}
		}

		//for (int i = 1; i <= n; i++) std::cout << a[i] << " "; std::cout << "\n";

		bool ok = true;
		for (int i = 0; i < q; i++) {
			long long l = query[i].l, r = query[i].r, ans = query[i].ans;
			long long tmp = gcd(a[l], a[l + 1]);
			for (int j = l + 1; j <= r; j++) tmp = gcd(tmp, a[j]);
			if (tmp != ans) { ok = false; break; }
		}

		if (!ok)
			std::cout << "Stupid BrotherK!\n";
		else {
			if (!a[1]) a[1] = 1;
			std::cout << a[1];
			for (int i = 2; i <= n; i++) {
				if (!a[i]) a[i] = 1;
				std::cout << " " << a[i];
			}
			std::cout << "\n";
		}
	}
}

